home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SNIP0492.ARJ / STRREV.C < prev    next >
C/C++ Source or Header  |  1991-09-12  |  349b  |  21 lines

  1. /*
  2. **  STRREV.C - reverse a string in place
  3. **
  4. **  public domain by Bob Stout
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. char *strrev(char *str)
  10. {
  11.       char *p1, *p2;
  12.  
  13.       for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
  14.       {
  15.             *p1 ^= *p2;
  16.             *p2 ^= *p1;
  17.             *p1 ^= *p2;
  18.       }
  19.       return str;
  20. }
  21.